#ifndef HUD_H
#define HUD_H


#ifdef DX9

#include "NeroEngine\NEntity.h"
#include "NeroEngine\NFactory.h"

#include <sstream>

#ifdef WIN_32
#include <d3dx9.h>
#include "Win32_DX9\Win32RenderEntity.h"
#endif

namespace Game
{
	class NPlatform;
}

extern Engine::NPlatform* GPlatform;

struct HudEntry
{
	std::string message;
	float x;
	float y;
};

class HUD : public Graphics::Win32RenderEntity
{
	RTTI_DECLARATIONS(HUD, Win32RenderEntity)

public:
	HUD();

	virtual ~HUD(void);

	virtual void Initialize();

	virtual void Deinitialize(){}

	virtual void Update(float gameTime);

	virtual void Render(float gameTime);

	void PrintText(const char* text, int size, int x, int y, DWORD color);

	void AddText(HudEntry text);

	void AddText(const char* label, float x = 0.0f, float y = 0.0f);

	template <class T> void AddText(const char* label, T value, float x = 0.0f, float y = 0.0f);

	template <class T> void AddText(const char* label, T value1, T value2, float x = 0.0f, float y = 0.0f);

	template <class T> void AddText(const char* label, T value1, T value2, T value3, float x = 0.0f, float y = 0.0f);

private:
	ID3DXFont* mFont;
	std::vector<HudEntry> mDiplayText;
	std::stringstream mStringStream;
};

ConcreteFactory(HUD, Engine::NEntity, HUD)

template<class T>
void HUD::AddText(const char* label, T value, float x, float y)
{
	mStringStream.str("");
	mStringStream.clear();
	mStringStream << label;
	mStringStream << value;
	
	HudEntry entry;
	entry.message = mStringStream.str();
	entry.x = x;
	entry.y = y;

	AddText(entry);
}

template<class T>
void HUD::AddText(const char* label, T value1, T value2, float x, float y)
{
	mStringStream.str("");
	mStringStream.clear();
	mStringStream << label;
	mStringStream << value1;
	mStringStream << ", ";
	mStringStream << value2;
	
	HudEntry entry;
	entry.message = mStringStream.str();
	entry.x = x;
	entry.y = y;

	AddText(entry);
}

template<class T>
void HUD::AddText(const char* label,  T value1, T value2, T value3, float x, float y)
{
	mStringStream.str("");
	mStringStream.clear();
	mStringStream << label;
	mStringStream << value1;
	mStringStream << ", ";
	mStringStream << value2;
	mStringStream << ", ";
	mStringStream << value3;
	
	HudEntry entry;
	entry.message = mStringStream.str();
	entry.x = x;
	entry.y = y;

	AddText(entry);
}

#endif
#endif